package com.andaily.domain.dto.account;

import com.andaily.domain.account.AccountStatisticsType;
import com.andaily.domain.shared.Application;
import com.andaily.domain.shared.paginated.DefaultPaginated;
import com.andaily.domain.shared.security.SecurityUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Shengzhao Li
 */
public class AccountStatisticsDetailsDTO extends DefaultPaginated<AccountDTO> {

    private AccountStatisticsType type;

    /**
     * 针对不同的{@link #type},该值的意义不一样.
     * <ul>
     * <li>type =  DAY , 该值是选择的日期, 如: 2013-04-23 </li>
     * </ul>
     */
    private String value;

    private boolean showMore = true;

    public AccountStatisticsDetailsDTO() {
        super(30);
    }

    public String getTitle() {
        String title = "统计明细";
        switch (type) {
            case DAY:
                title = value;
                break;
            case ACCOUNT_TYPE:
                title = "按类型统计明细";
                break;
            case INCOME:
                title = "按收入统计明细";
                break;
            case EXPENDITURE:
                title = "按支出统计明细";
                break;
            case MONTH:
                title = value;
                break;
        }

        return title;
    }

    public boolean isShowMore() {
        return showMore;
    }

    public void setShowMore(boolean showMore) {
        this.showMore = showMore;
    }

    public Map<String, Object> queryParamMap() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("prePageSize", getPerPageSize());
        map.put("startIndex", getStartIndex());
        map.put("ownerGuid", SecurityUtils.currentUserGuid());

        map.put("sType", type.name());
        map.put("sValue", value);
        map.put("incomeTypeGuid", Application.incomeAccountTypeGuid());
        return map;
    }


    @Override
    public void afterLoad() {
        this.showMore = isHasNext();
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public AccountStatisticsType getType() {
        return type;
    }

    public void setType(AccountStatisticsType type) {
        this.type = type;
    }

}
